Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

androidApp/src/main/kotlin/org/meshtastic/app/map/MapLayer.kt claude/jdk-25-upgrade-e9b32c (498ff922) Text, 3.68 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map

Tff7b72import T7ee787android.content.Context
Tff7b72import T7ee787android.net.Uri
Tff7b72import T7ee787android.provider.OpenableColumns
Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787org.meshtastic.core.common.util.nowMillis
Tff7b72import T7ee787kotlin.uuid.Uuid

T8b949e/**
* Flavor-neutral map-layer model shared by the Google (Google Maps data layer) and F-Droid (OSMdroid overlay) flavors.
* Only the final overlay draw is flavor-specific; the layer list, storage, and import logic live in [MapLayersManager].
*/
Tff7b72enum Tff7b72class T56d364LayerType Tb4b4b4{
Te6edf3KMLTb4b4b4,
Te6edf3GEOJSONTb4b4b4,
Tb4b4b4}

Tff7b72data Tff7b72class T56d364MapLayerItemTb4b4b4(
Tff7b72val Te6edf3idTb4b4b4: Tffa657String Tff7b72= Te6edf3UuidTb4b4b4.Te6edf3randomTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toStringTb4b4b4(Tb4b4b4)Tb4b4b4,
Tff7b72val Te6edf3nameTb4b4b4: Tffa657StringTb4b4b4,
Tff7b72val Te6edf3uriTb4b4b4: Te6edf3Uri? Tff7b72= Tff7b72nullTb4b4b4,
Tff7b72val Te6edf3isVisibleTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72trueTb4b4b4,
Tff7b72val Te6edf3layerTypeTb4b4b4: Te6edf3LayerTypeTb4b4b4,
Tff7b72val Te6edf3isNetworkTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
T8b949e/** UI indicator: whether a refresh is in flight (drives the sheet/toolbar spinner). */
Tff7b72val Te6edf3isRefreshingTb4b4b4: Tffa657Boolean Tff7b72= Tff7b72falseTb4b4b4,
T8b949e/**
* Monotonic counter bumped on refresh so the flavor renderers reliably re-read the layer. A [StateFlow] conflates
* transient values, so a bounced boolean flag can be missed — an ever-increasing token cannot.
*/
Tff7b72val Te6edf3refreshTokenTb4b4b4: Tffa657Int Tff7b72= T79c0ff0Tb4b4b4,
Tb4b4b4)

Tff7b72private Tff7b72val Te6edf3KML_EXTENSIONS Tff7b72= Te6edf3listOfTb4b4b4(Ta5d6ff"Ta5d6ffkmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffkmzTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffvnd.google-earth.kml+xmlTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffvnd.google-earth.kmzTa5d6ff"Tb4b4b4)
Tff7b72private Tff7b72val Te6edf3GEOJSON_EXTENSIONS Tff7b72= Te6edf3listOfTb4b4b4(Ta5d6ff"Ta5d6ffgeojsonTa5d6ff"Tb4b4b4, Ta5d6ff"Ta5d6ffjsonTa5d6ff"Tb4b4b4)

T8b949e/**
* Resolve a file extension or MIME subtype (e.g. `geojson`, `vnd.geo+json`) to a [LayerType], or null if unsupported.
*/
Tff7b72fun Td2a8ffresolveLayerTypeTb4b4b4(Te6edf3extensionOrMimeTb4b4b4: Tffa657String?Tb4b4b4)Tb4b4b4: Te6edf3LayerType? Tff7b72= Tff7b72when Tb4b4b4(Te6edf3extensionOrMimeTff7b72?.Te6edf3lowercaseTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Tff7b72in Te6edf3KML_EXTENSIONS Tff7b72-Tff7b72> Te6edf3LayerTypeTb4b4b4.Te6edf3KML

Tff7b72in Te6edf3GEOJSON_EXTENSIONS Tff7b72-Tff7b72> Te6edf3LayerTypeTb4b4b4.Te6edf3GEOJSON

T8b949e// MIME subtypes the content resolver may report for GeoJSON that aren't a bare "geojson"/"json".
Ta5d6ff"Ta5d6ffgeo+jsonTa5d6ff"Tb4b4b4,
Ta5d6ff"Ta5d6ffvnd.geo+jsonTa5d6ff"Tb4b4b4,
Tff7b72-Tff7b72> Te6edf3LayerTypeTb4b4b4.Te6edf3GEOJSON

Tff7b72else Tff7b72-Tff7b72> Tff7b72null
Tb4b4b4}

T8b949e/**
* Resolve a display file name for [this] URI, querying the content resolver for `content://` URIs. Untrusted providers
* (share/open-with from other apps) can throw or return a null display name, so guard both and fall back to the URI's
* last path segment.
*/
Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffNestedBlockDepthTa5d6ff"Tb4b4b4)
Tff7b72fun Te6edf3UriTb4b4b4.Td2a8ffgetFileNameTb4b4b4(Te6edf3contextTb4b4b4: Te6edf3ContextTb4b4b4)Tb4b4b4: Tffa657String Tb4b4b4{
Tff7b72var Te6edf3name Tff7b72= Te6edf3lastPathSegment Tff7b72?: Ta5d6ff"Ta5d6fflayer_Tffd700$Te6edf3nowMillisTa5d6ff"
Tff7b72if Tb4b4b4(Te6edf3scheme Tff7b72=Tff7b72= Ta5d6ff"Ta5d6ffcontentTa5d6ff"Tb4b4b4) Tb4b4b4{
Tff7b72try Tb4b4b4{
Te6edf3contextTb4b4b4.Te6edf3contentResolverTb4b4b4.Te6edf3queryTb4b4b4(Tff7b72thisTb4b4b4, Tff7b72nullTb4b4b4, Tff7b72nullTb4b4b4, Tff7b72nullTb4b4b4, Tff7b72nullTb4b4b4)Tff7b72?.Te6edf3use Tb4b4b4{ Te6edf3cursor Tff7b72-Tff7b72>
Tff7b72if Tb4b4b4(Te6edf3cursorTb4b4b4.Te6edf3moveToFirstTb4b4b4(Tb4b4b4)Tb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3displayNameIndex Tff7b72= Te6edf3cursorTb4b4b4.Te6edf3getColumnIndexTb4b4b4(Te6edf3OpenableColumnsTb4b4b4.Te6edf3DISPLAY_NAMETb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3displayNameIndex Tff7b72!Tff7b72= Tff7b72-T79c0ff1Tb4b4b4) Tb4b4b4{
Te6edf3cursorTb4b4b4.Te6edf3getStringTb4b4b4(Te6edf3displayNameIndexTb4b4b4)Tff7b72?.Te6edf3let Tb4b4b4{ Te6edf3name Tff7b72= Tffa657it Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tb4b4b4} Tff7b72catch Tb4b4b4(Tf0883e@SuppressTb4b4b4(Ta5d6ff"Ta5d6ffTooGenericExceptionCaughtTa5d6ff"Tb4b4b4) Te6edf3eTb4b4b4: Te6edf3ExceptionTb4b4b4) Tb4b4b4{
T8b949e// Keep the lastPathSegment fallback assigned above rather than crashing the import.
Te6edf3LoggerTb4b4b4.Te6edf3withTagTb4b4b4(Ta5d6ff"Ta5d6ffMapLayerTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3wTb4b4b4(Te6edf3eTb4b4b4) Tb4b4b4{ Ta5d6ff"Ta5d6ffFailed to resolve display name for content URI; using fallbackTa5d6ff" Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Tff7b72return Te6edf3name
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s